# CalPiV2.py

import random
import time
DARTS = 1000*1000
hits = 0.0
start = time.perf_counter()
random.seed(10)
for i in range(DARTS):
    x = random.random()
    y = random.random()
    dist = pow(x ** 2 + y ** 2, 0.5)
    if dist <= 1.0:
        hits = hits + 1
pi = 4 * (hits / DARTS)
end = time.perf_counter()
print('圆周率值是:{:.5f}'.format(pi))
print('运行时间是:{:.5f}'.format(end-start))
